package com.halden.mycache.support.listener.impl;

import com.alibaba.fastjson.JSON;
import com.halden.mycache.support.listener.ISlowLogListener;
import com.halden.mycache.support.listener.SlowLogContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: halden
 * @Data:2023/2/11 17:05
 * @Description:
 */
public class SlowLogListener implements ISlowLogListener {

    private static Logger logger = LogManager.getLogger(SlowLogListener.class);

    @Override
    public void listen(SlowLogContext slowLogContext) {
        logger.warn("[Slow] methodName: {}, params: {}, cost time: {}",
                slowLogContext.methodName(), JSON.toJSON(slowLogContext.params()), slowLogContext.costTimeMills());
    }
}
